//-------------------------------------------------------------------------------------------------
// <copyright file="Utility.cs" company="OfficeClip LLC">
// Copyright (c) OfficeClip LLC.  All rights reserved.
// </copyright>
//-------------------------------------------------------------------------------------------------

namespace OfficeClip.OpenSource.StyleFix
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

    public class Utility
    {
        private string _output = string.Empty;
        private string _error = string.Empty;

        public string Output
        {
            get { return this._output; }
        }

        public string Error
        {
            get { return this._error; }
        }

       public int Run(string dir, string programPath, string processArgument, bool showOutput)
        {
            int retVal;
            try
            {
                string fullPath = string.Concat(programPath, " ", processArgument);
                ProcessStartInfo processStartInfo = new ProcessStartInfo(
                    string.Format(@"{0}\{1}", dir, programPath));
                processStartInfo.Arguments = processArgument;

                // processStartInfo.WindowStyle = ProcessWindowStyle.Minimized;
                processStartInfo.RedirectStandardError = true;
                processStartInfo.RedirectStandardOutput = true;
                processStartInfo.UseShellExecute = false;
                System.Diagnostics.Process process = System.Diagnostics.Process.Start(processStartInfo);

                // Utility.Constants.MimimizeWindow(process);
                this._output = process.StandardOutput.ReadToEnd();
                this._error = process.StandardError.ReadToEnd();
                process.WaitForExit();
                retVal = process.ExitCode;
            }
            catch (Exception e)
            {
                retVal = -100;
            }

            return retVal;
        }
    }
}
